import {CHANGE_INPUT_VALUE, ADD_TODO_ITEM, DELETE_TODO_ITEM, INIT_LIST, GET_INIT_LIST} from './actionTypes';
import axios from 'axios';

export const getInputChangeAction = (value) => ({
  type: CHANGE_INPUT_VALUE,
  value
})

export const getAddItemAction = () => ({
  type: ADD_TODO_ITEM
})

export const getDeleteItemAction = (index) => ({
  type: DELETE_TODO_ITEM,
  index
})

export const getInitListAction = (data) => ({
  type: INIT_LIST,
  data
})

export const getInitList = () => ({
  type: GET_INIT_LIST
})

// 引用redux-thunk中间件后 可以return 一个函数(action可以不仅仅可以是对象)
export const getTodoList = () => {
  return (dispatch) => {
    // axios.get('/api/todolist').then(res=> {
    //   const data = res.data;
    //   const action = getInitListAction(data);

    //   dispatch(action);
    // })
  }
}